﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;

namespace HttpHandlers
{
    public class HttpHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }
        }

        Bitmap image;

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/png";

            string str = context.Server.UrlDecode(context.Request.QueryString["name"]);

            image = new Bitmap(800,600);
            Graphics gfx = Graphics.FromImage(image);
            gfx.FillRectangle(Brushes.DarkOrange, new Rectangle(0, 0, 800, 600));
            Font font = new Font("Sans",40);
            gfx.DrawString(str, font, Brushes.Black, 200, 200);
            image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

            image.Dispose();
            gfx.Dispose();
        }
    }
}